package top.lywivan.dao;

import top.lywivan.pojo.Brand;
import org.apache.ibatis.annotations.*;

import java.util.List;

public interface BrandDao {
    @Select("select id, brandName, companyName, ordered, description, status from brand")
    List<Brand> queryAllBrand();

    @Insert("insert into brand(id, brandName, companyName, ordered, description, status) values (#{id}, #{brandName}, #{companyName}, #{ordered}, #{description}, #{status})")
    void addBrand(Brand brand);

    void deleteBrandByIds(@Param("ids") int[] ids);

    @Select("select count(id) from brand")
    Long queryTotalCount();

    @Select("select id, brandName, companyName, ordered, description, status from brand limit #{startIndex},#{pageSize}")
    List<Brand> queryPageList(@Param("startIndex") Integer startIndex,@Param("pageSize") Integer pageSize);

    @Delete("delete from brand where id=#{id}")
    void deleteBrandById(Integer id);

    Long queryTotalCountWhere(Brand brand);

    List<Brand> queryPageListWhere(@Param("brand") Brand brand,@Param("startIndex")Integer startIndex,@Param("pageSize")Integer pageSize);

    @Select("select id, brandName, companyName, ordered, description, status from brand where id=#{id}")
    Brand queryBrandById(Integer id);

    @Update("update brand set brandName=#{brandName}, companyName=#{companyName}, ordered=#{ordered}, description=#{description}, status=#{status} where id=#{id}")
    void updateBrandById(Brand brand);
}
